var serveStatic = require("serve-static");
var express = require('express');
var proxy = require('http-proxy-middleware');
var cookieParase = require('cookie-parser');
var request = require('request');
var mime = require('mime');
var app = express();

var port=3000
app.use(cookieParase());
//静态资源
app.use(serveStatic("src"));
app.listen(port);
express.static.mime.define({
	'application/x-font-woff': ['woff'],
	'application/font-woff': ['woff']
 }); 


app.use('/login', function (req,res) {

	// var url="http://127.0.0.1:8080/api/user/login";
	// var requestData={"account":"13311080031","password":""};
	// request({
	// 	url: url,
	// 	method: "POST",
	// 	json: true,
	// 	headers: {
	// 		"content-type": "application/json",
	// 	},
	// 	body: JSON.stringify(requestData)
	// }, function(error, response, body) {
	// 	if (!error && response.statusCode == 200) {
	// 		console.log(body) // 请求成功的处理逻辑
	// 		res.send(body)
	// 	}
	// }); 
	res.cookie('wt', 'BVzJRQFVoVmwEN1YwAT5cPFNkATI.',{maxAge: 86400000 * 10});
	res.send('登陆成功')
    
})
app.use('/', proxy({
    target: "https://blue-m.weizhipin.com/",
    //target: "http://api.kanzhun-inc.com/mock/66/",
    changeOrigin: true
}));
console.log("服务器已启动 http://127.0.0.1:"+port)